In [14]:
import numpy as np
import math
def nios_memory_calculations(MemSection_width, MemSection_depth, MEMORY_SIZE, FrameSize, subpx):
# calculations
m_Data_frame_length = FrameSize
numberOfSections = math.floor(float(MEMORY_SIZE)/float(MemSection_width*MemSection_depth))
usableMemSize = int(numberOfSections * (MemSection_width*MemSection_depth))
m_number_of_sections = MEMORY_SIZE/(MemSection_width*MemSection_depth)
m_N_Mem_Rows = MemSection_width
m_Section_Size = (MemSection_width*MemSection_depth)/m_Data_frame_length # in frame numbers
N_Frames_DDR_TH = usableMemSize / m_Data_frame_length # number of frames for the full memory
Mem_Row_Size_Frame = N_Frames_DDR_TH / m_N_Mem_Rows # number of frames for the depth direction
m_Mem_Row_Size = Mem_Row_Size_Frame * m_Data_frame_length # memory depth size in bytes
m_N_Mem_Rows_Inv = (2**32)/m_N_Mem_Rows # ?
print("-- Nios Memory Calculations ------")
print("m_number_of_sections : {0:8} (0x{0:X})".format(int(m_number_of_sections)))
print("m_N_Mem_Rows : {0:8} (0x{0:X})".format(int(m_N_Mem_Rows)))
print("m_Section_Size : {0:8} (0x{0:X})".format(int(m_Section_Size)))
print("N_Frames_DDR_TH : {0:8} (0x{0:X})".format(int(N_Frames_DDR_TH)))
print("Mem_Row_Size_Frame : {0:8} (0x{0:X})".format(int(Mem_Row_Size_Frame)))
print("m_Mem_Row_Size : {0:8} (0x{0:X})".format(int(m_Mem_Row_Size)))
print("m_N_Mem_Rows_Inv : {0:8} (0x{0:X})".format(int(m_N_Mem_Rows_Inv)))# memory
print("")
def calmar_cb_testbench_memory_calculations(MemSection_width, MemSection_depth, MEMORY_SIZE, FrameSize, subpx):
# calculations
m_Data_frame_length = FrameSize
numberOfSections = math.floor(float(MEMORY_SIZE)/float(MemSection_width*MemSection_depth))
usableMemSize = int(numberOfSections * (MemSection_width*MemSection_depth))
m_number_of_sections = MEMORY_SIZE/(MemSection_width*MemSection_depth)
m_N_Mem_Rows = MemSection_width
m_Section_Size = (MemSection_width*MemSection_depth)/m_Data_frame_length # in frame numbers
N_Frames_DDR_TH = usableMemSize / m_Data_frame_length # number of frames for the full memory
Mem_Row_Size_Frame = N_Frames_DDR_TH / m_N_Mem_Rows # number of frames for the depth direction
m_Mem_Row_Size = Mem_Row_Size_Frame * m_Data_frame_length # memory depth size in bytes
m_N_Mem_Rows_Inv = (2**32)/m_N_Mem_Rows # ?
print("-- Calmar Controller Board Testbench ------")
print("Memory Size : {0:8} kBytes (0x{0:X})".format(int(MEMORY_SIZE/1024)))
print("Memory Rows : {0:8} pixels (lines) (0x{0:X})".format(int(m_N_Mem_Rows)))
print("Memory Row Size : {0:8} bytes (0x{0:X})".format(int(m_Mem_Row_Size)))
print("")
In [15]:
# memory
MemSection_width = 1536*4
MemSection_depth = 8192
MEMORY_SIZE = 1073741824 # Bytes
# ethernet
FrameSize = 8192
# fix values
subpx = 32 # scaling factor fpga
nios_memory_calculations(MemSection_width, MemSection_depth, MEMORY_SIZE, FrameSize, subpx)
calmar_cb_testbench_memory_calculations(MemSection_width, MemSection_depth, MEMORY_SIZE, FrameSize, subpx)
In [16]:
# memory
MemSection_width = 2048*4
MemSection_depth = 24576
MEMORY_SIZE = 1073741824 # Bytes
# ethernet
FrameSize = 8192
# fix values
subpx = 32 # scaling factor fpga
nios_memory_calculations(MemSection_width, MemSection_depth, MEMORY_SIZE, FrameSize, subpx)
calmar_cb_testbench_memory_calculations(MemSection_width, MemSection_depth, MEMORY_SIZE, FrameSize, subpx)